Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show slatepack QR codes #655

Merged
merged 2 commits into from
Jul 12, 2022
Merged

Conversation

cliik
Copy link
Contributor

@cliik cliik commented Jul 9, 2022

Resolves stakervali/grin-wishlist#12.
This PR addresses the slatepack QR wishlist feature.

This PR shows a QR code when slatepacks are generated. The second slatepack (e.g. response when receiving) results in quite a large QR code, so I think someone should approve that from a UX perspective, but below is an example of the QR output when initiating a send.

$ .grin-wallet send -m 0.5
Password: 
No recipient Slatepack address or provided address invalid. No payment proof will be requested.
./testdir/slatepack/4d003e43-b377-4880-8bdd-4e70ba4499e7.S1.slatepack

Slatepack data follows. Please provide this output to the other party

--- CUT BELOW THIS LINE ---

BEGINSLATEPACK. YLpmbZFYB5gcEbq W7pdEknbFxART1L nTnvKkES8REBmV1 D6ohYYMVA8HqXnF yTGqKser9Srb6wZ pSYxR497rt4oiok M5h6TyfZijibxZV acQo2VnHBvDE8XY WoLMumptd3PeRgb 3DudXdb9XZBdGX3 XjxUfiKCSsLkabF aubR26yZ7gss2Fh 5tjKDrDVFoUcwnJ R96g6EQb3QkAqjh ydk3ezNypJJ4kaf 6AAfCJXqKvTjroL rYDpti3b84k69UD QCMUgXnRKVY4T2A 7fT2qhReQnFSXD9 sfLEkYcrC31Axmr 3YVNYw. ENDSLATEPACK.

--- CUT ABOVE THIS LINE ---

Slatepack data was also output to

./testdir/slatepack/4d003e43-b377-4880-8bdd-4e70ba4499e7.S1.slatepack

                                                                   
 █▀▀▀▀▀█ ▄▄ █▄▀███▄▀▄▄▄  ▀ ▄▀▀▄█ ▄▀ ▄██ ▀ ▄▀█ █▄▀▄▀ ▄▀▀ ▀▄ █▀▀▀▀▀█ 
 █ ███ █ ▄▀▄█ █▀ █▄ ▄ █▄███ ▀▀▄▄▀▄▄ ███  ▄▀  ▄ ▀▀▀█▀  ██▄▀ █ ███ █ 
 █ ▀▀▀ █ ▄▀▀  ▀▀▀▀▄▀ ▄██ ▄▄   ▄█▀▀▀█▄ ▄ ▀▄▄█▄  ▀▀██  ▄▄▄ ▀ █ ▀▀▀ █ 
 ▀▀▀▀▀▀▀ ▀▄█▄▀▄█▄█ █▄█▄▀ █▄▀ █ █ ▀ █▄█▄▀ ▀▄█▄▀ ▀▄█▄█ ▀ ▀ ▀ ▀▀▀▀▀▀▀ 
 ████▀▄▀▀██▄█▀ █▀  ▄█ ▀  ▀▄▀  █▀█▀████ ▀█▄▀▀ ▀██ ▀▄▀▀ █  ▀█ █▄▀▄▀  
 ▀ ▄▀█▄▀ ▄█▀██▀██▀██▀▄▀▀▀█▄▀▄▀▄▄█ ▄▄█▄█  ▀█▀█▀▄▄▀▄█▄▄ ▀▀▀▀▄███▄ █  
 ▄ ▀▀ █▀   ▀▄█    ██▀ ▀ ▀▄▄ ▄ ██▄█ ▀ ▀▄ ▀█▄▄▄▀ ██▄▀ █▀█▀█▄█▀ ▄█▄ █ 
 ▀▀▄ ▄▀▀ █▀▀ ▀██▀  ▄▀ ▄▀   ▀▀███▄ ▄▄█▄█ █▀▄█ ▄  ▀██ ▀ ███▄ █ ▄▀    
 █▀█▀█ ▀▀▄▄▄█ ▄█▀█▄██▄  ▀▀     ▄  ▄ ▄▀ █▄▀▀▀▀ ▄▀███ ▀▀▄▄█  ▄▀▀▀ ▄  
  ▄▄▀▀▄▀▄▄ ▄ █▄█ ▄▄█▀█▀▀ ▄▀▄█▄▀█▀   ▄█▀█▄  ██  ▄██ ▄▄ █  █  █ █ █▄ 
 ▄▀█▄▀▀▀██ ▀▀▄█▀▄ ▄█▀▄█ ▀▀ █▄ ▄█▀ ▄█ █▀██▀▄█  █ ▄▄█▄█  █▄ █▄█▀▄  ▀ 
  ▄█▄█ ▀█   ▄ ▄ ▄ ▀  █▄█▄▄  ▄  ▀███ ▄▄█ █▀▀▀ ▀  ██▀▄▀▀▀▀  ▀▄▄█▄▄▄█ 
 ▄▀▀█▄█▀▀▀▄█▀█▀█▀ ███▄  ▀▀▀   █▀▄▄  █▀▄▀  ▀ ██▄▄ ▄▀▄▀▀▄   ▀▄█ ▀▄▀▀ 
  ▄▄ ▀▀▀▀▀   █ ▄██▄▄▄▄▀ ▀ ▀▄▀▀ █▄  ▄ █ ▄▀ █▀▄▀▀ ▄▄▀▄ ▀▄▀  ▄ ▄█ ▄█  
 ▄▀▀██▀▀ █ █▄█▄█▀▄▄▄▄▄ ▀█▄▄  ███ ██ ▀▄▄██ ▀▀ ▀   █ █▄▄▄▀ ▄▀▄██▀▄▀█ 
 ▄▄███▀▀▀█  ▀█▄ ▀█▀▄▄██▄▀▄█▀▄  █▀▀▀██▀█ ████ █    ▀ ▄▄██▄█▀▀▀█▄█ █ 
 ▄██▄█ ▀ █▀▀▄▄▄▀▄ ▄▄▀▄ ▀█▀▄▀ ▄██ ▀ █▄▀▀▄▄▄▄█▀███▀▀▀▀  ▀▀▀█ ▀ █  ▄  
 ▀▄ ▄▀▀▀▀█▀▄▀▀█▄ ▄▀ ▄▄█  █▀▄██████▀▀ ██▄  ▄█▀ █▄██ █▄  ▀▀█▀██▀▄▀█▀ 
 ▀ █▀▄▄▀ █▀▀ ▀█▄ ▄▀▄▀ █ ▀██  ▄▄ █▄██ ▀▀▄▄  ▀ █▄ ▄█▄▄█▄█▄█▀▄▀ ██▀▀▀ 
 ▄▀ █▀▄▀ ▀▀▀▄▄▀█▀ ▀█▄▀  ▄▄▀█▀▄▄▀▄▄▄▀▄▄▀▄  ▀█▄ ▄▄▄██ █▀▀▀▀ ▀▀█▀▄▀▀▄ 
  ▄▀▄██▀▀▄▀▄█  █▄▄█▄█▄▀ ▀█▄   ▄▀ ▄▄▄▄▀  ▀  ▄▀ █ ▀▀ ██▄ █ █▄▀▄ ▀ █  
 █▀█▄ ▄▀▀█▄▀▄█ ▀ ▄   ▀▄▄▄▄▄▀▀▀  █  ▀▄█▀ █ ▀▀█ ▄▄ ▄▀ ▀▀█▀▀▄█▀▀▀▀▄██ 
  ▄▄▄▄▀▀▄▄██▀ ▄▄▄ ██  █ ▄ ▄ █ ██  █ ██▄ ▀▄█▀▄█▀▄▀█▄█▀▀▄▀▄▄▄▀ █▄▄▄  
 █▄▀█ ▀▀ ▄▄▄▀█▄▄▄ ▀▀   ▀▀▀  █▀ ▀ ▀▀▀▄▀█ ▀▄ █▄▀  █ █ ▀▄▄█▀██▀ ▀▀▄▄▄ 
 ██ ▄██▀ █▀▄▄▀██▄ ██▀▄▀▀▀▀█ ▄ ▄ █  ▀ █ ▀▀▄▀ ▄ ▄ █▀  █▀▄ ▄▄█ ██▄ ▀  
 ▀  ▀▀█▀▀▀█▄ ▀▀ ▀▄▄█ ██ ▀▀█▄ ▄▄▀▀▄▀ ██▀▀  ███ █▀▄█▀     ▀▀ ▀ ▀█▀▄▀ 
  ▀▄ ██▀▀ █▀▄▀▀█ ▄▄█▀ ▄ ███▄█ █▀  ▄▀  ▄█  ▀█▄█   ▄█ ▀▀ ▀ █ ▀ ▀██ ▀ 
 ▄ ▀█ ▀▀▀▀▄▄▀█ ██ ▀▄ ▄▀ ▄  ▄█▄▄ ▀▄ ▀▄▄█ ▀  █▄▀▄▄█▄▀▄▀ ▀██▀█ ▄█ ▀▄▀ 
  ▀▀ ▀ ▀▀██   ▄▄█▄▄▄█  ▀██▄ ▄  █▀▀▀██ █▄▀▀ ▀▀▀▀   ▄▀  █▄ █▀▀▀█▀▄ ▀ 
 █▀▀▀▀▀█ ▀▀▀▀ ▄▄█▄ ▀▄▄▄▀▄▀ ▀██▄█ ▀ █▄▄█▄ ▀█▀▄▀ ▄▄▄▀  ▀▄▀ █ ▀ █   ▀ 
 █ ███ █ ███  █▀▀▄█▄ ▄▄▀▄█ ▀ ▀ ██▀▀▀▀ ▄ ▄ ▀▀▀█ ▄ ▄▀ ██ ▀█▀▀█▀██▄▄▀ 
 █ ▀▀▀ █ ████▀ ▄▀█▄█ ▀  █▄   ▀ ▀█▄▄▀  █ ▄▀▀█▄▀   ▄▀ ▄▄██ ▀▄▄█▀▄▀█▄ 
 ▀▀▀▀▀▀▀ ▀ ▀ ▀▀    ▀▀ ▀ ▀▀▀ ▀    ▀▀▀ ▀▀▀▀   ▀ ▀▀ ▀ ▀▀ ▀▀▀▀  ▀▀  ▀  



The slatepack data is NOT encrypted

Command 'send' completed successfully

@stakervali
Copy link

If I recall correctly this was requested by @marekyggdrasil, I will notice him.
Since QR is a standard a relatively big QR image is inevitable given the size of slatepack text. From UX persective it can be made optional with a flag. I think it looks very good, congratz!

@marekyggdrasil
Copy link

Really cool! Just one question @cliik , what happens if user runs the command with a tiny window and slatepack is not visible. Then adjustes the terminal window size, will the QR code become properly visible or is it required to run the command again in terminal window of larger dimensions?

@cliik
Copy link
Contributor Author

cliik commented Jul 9, 2022

From UX persective it can be made optional with a flag

Good idea. I will make it optional.

what happens if user runs the command with a tiny window and slatepack is not visible. Then adjustes the terminal window size, will the QR code become properly visible or is it required to run the command again in terminal window of larger dimensions?

@marekyggdrasil the QR is just a string of characters. If you resize your terminal (depending on your terminal settings), it should show the QR code correctly. At the end of the day, if you want, you can copy+paste the characters into any other text editor to see the QR code outside of the terminal.

Its potentially possible to render the QR code as an image instead, and save the image to a file. Or automatically open the image in a pop-up window, but I think this would be much more complicated, add system dependencies, and not be easy to do cross-platform. Just printing characters in the terminal seemed like the best balance of functionality & simplicity.

@cliik
Copy link
Contributor Author

cliik commented Jul 9, 2022

@stakervali 97c10bd makes the QR codes optional, and I agree this improves UX. Thanks for the suggestion.

@marekyggdrasil
Copy link

Its potentially possible to render the QR code as an image instead, and save the image to a file. Or automatically open the image in a pop-up window, but I think this would be much more complicated, add system dependencies, and not be easy to do cross-platform. Just printing characters in the terminal seemed like the best balance of functionality & simplicity.

I totally agree, that would be an overkill. I think the way you designed it is a perfect compromise between usability and extra overhead.

@yeastplume
Copy link
Member

This all looks good, thanks for the PR!

@yeastplume yeastplume merged commit 95bb4c4 into mimblewimble:master Jul 12, 2022
@cliik cliik deleted the slatepack-as-qr branch July 13, 2022 04:00
bayk added a commit to mwcproject/mwc-wallet that referenced this pull request Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display slatepacks as QR codes in CLI
4 participants